﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnalyseCrmMana;
using Newtonsoft.Json;

namespace AnalyseCRM.InteractiveData
{
    public partial class PublicAjax : System.Web.UI.Page
    {
        private string _paramValue = "", _paramType = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["paramvalue"] != null)
            {
                _paramValue = Server.UrlDecode(Request["paramvalue"].ToString());
            }
            if (Request["paramtype"] != null)
            {
                _paramType = Request["paramtype"].ToString();
            }
            Response.Write(buildHtml(_paramValue, _paramType));
        }


        public StringBuilder buildHtml(string prparamValue, string prparamType)
        {
            StringBuilder returnValue = null;
            switch (prparamType)
            {
                case "_getDictQuery":
                    returnValue = new StringBuilder();
                    PublicMana pubmana = new PublicMana();
                    IList<DownListInfo> downlist = pubmana.getSelectByParent(prparamValue);
                    if (downlist != null && downlist.Count > 0)
                        returnValue.Append(JsonHelper.ListToJson(downlist));
                    else
                        returnValue.Append("none");                    
                    break;
                default:
                    break;
            }            
            return returnValue;

        }
    }
}